
#include "nx_api.h"

#ifdef __PRODUCT_NETXDUO__

#include "netx_mdns_test.h"

/* Frame (75 bytes) */
static const unsigned char pkt1[75] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0xec, 0x17, /* ..^..... */
0x2f, 0xbd, 0xa4, 0xb1, 0x08, 0x00, 0x45, 0x00, /* /.....E. */
0x00, 0x3d, 0x01, 0x81, 0x00, 0x00, 0xff, 0x11, /* .=...... */
0x11, 0x81, 0xc0, 0xa8, 0x07, 0x0a, 0xe0, 0x00, /* ........ */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x29, /* .......) */
0xa9, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* .&...... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01                                /* ... */
};

/* Frame (110 bytes) */
static const unsigned char pkt2[110] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
0x00, 0x60, 0x00, 0x08, 0x40, 0x00, 0xff, 0x11, /* .g..@... */
0x90, 0x47, 0x0a, 0x00, 0x00, 0x42, 0xe0, 0x00, /* .@...B.. */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x4c, /* .......S */
0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* .9...... */
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01, 0x00, 0x00, 0x11, 0x94, 0x00, /* ......d. */
0x1d, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, /* ..ARMMDN */
0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, 0x69, /* STest._i */
0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05, /* pp._tcp. */
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00              /* local... */
};

/* Frame (110 bytes) */
static const unsigned char pkt3[110] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
0x00, 0x60, 0x00, 0x08, 0x40, 0x00, 0xff, 0x11, /* .g..@... */
0x90, 0x47, 0x0a, 0x00, 0x00, 0x42, 0xe0, 0x00, /* .@...B.. */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x4c, /* .......S */
0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* .9...... */
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, /* ......._ */
0x69, 0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, /* ipp._tcp */
0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, /* .local.. */
0x0c, 0x00, 0x01, 0x00, 0x00, 0x11, 0x93, 0x00, /* ......d. */
0x1d, 0x0b, 0x41, 0x52, 0x4d, 0x4d, 0x44, 0x4e, /* ..ARMMDN */
0x53, 0x54, 0x65, 0x73, 0x74, 0x04, 0x5f, 0x69, /* STest._i */
0x70, 0x70, 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05, /* pp._tcp. */
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00              /* local... */
};

static MDNS_SERVICE mdns_service = {"ARMMDNSTest", "_ipp._tcp", NX_NULL, NX_NULL, 4500, 0, 0, 80, NX_MDNS_RR_SET_UNIQUE, 0};

MDNS_TEST_SEQ mdns_duplicate_answer_suppression[] = {
    {TITLE, "Duplicate answer suppression", 28, 0},
    {MDNS_SERVICE_ADD, (char*)&mdns_service, 0, 0},
    {WAIT, NX_NULL, 0, 5},
    {DUMP, NX_NULL, 0, 0},

    /* Inject query. */
    {INJECT, (char*)&pkt1[0], sizeof(pkt1), 0},

    /* Check response. */
    {MDNS_CHECK_ANY_V4, NX_NULL, MDNS_FLAG_RESPONSE, 1},

    {WAIT, NX_NULL, 0, 3},
    {DUMP, NX_NULL, 0, 0},

    /* Inject query and response. */
    {INJECT, (char*)&pkt1[0], sizeof(pkt1), 0},
    {INJECT, (char*)&pkt2[0], sizeof(pkt2), 0},

    /* No response should be received. */
    {MDNS_REJECT_ANY_V4, NX_NULL, MDNS_FLAG_RESPONSE, 1},

    {WAIT, NX_NULL, 0, 3},
    {DUMP, NX_NULL, 0, 0},

    /* Inject query and response. The TTL in response is 100 which is less than 101. */
    {INJECT, (char*)&pkt1[0], sizeof(pkt1), 0},
    {INJECT, (char*)&pkt3[0], sizeof(pkt3), 0},

    /* Expect a response. */
    {MDNS_CHECK_ANY_V4, NX_NULL, MDNS_FLAG_RESPONSE, 1}
};

int mdns_duplicate_answer_suppression_size = sizeof(mdns_duplicate_answer_suppression) / sizeof(MDNS_TEST_SEQ);

#endif /* __PRODUCT_NETXDUO__  */

